#ifndef _CENGINE_H
#define _CENGINE_H

#include <vector>
#include <map>
#include <string>
#include <string.h>
#include <algorithm>
#include <iterator>

using namespace std;

#define MAPXSIZE 80
#define MAPYSIZE 25

class CObject
{
	public:
		CObject();
		virtual ~CObject();
		
		virtual void Run();
		virtual void Input(int e);
		virtual void Draw(int p);
		virtual void Clear();
		virtual void Message(int m);
		void Message(string m);
		virtual CObject *SpawnSelf(int x,int y);
		
		bool CollideMap(int x,int y);
		CObject *CollideObject(int n);
		int GetType();
		void Die();
		
		int m_X,m_Y;
		int m_SizeX,m_SizeY;
		int m_Tile,m_Type,m_DrawPass;
		bool m_Collide,m_Shown,m_Clear,m_Die;
		int m_MasterNum,m_Amount;
		string Name;
		map<string,int> Vars;
		map<string,bool> Flags;
		map<string,map<string,string> > Strings;
		vector<CObject *(*)(CObject *,string)> AI;
};


class CRoom
{
	public:
		CRoom();
		CRoom(int n);
		virtual ~CRoom();
		
		virtual void Run();
		virtual void Input(int e);
		virtual void Draw();
		void CenterCamera(int x,int y);
		void Clear();
		
		int m_Map[MAPXSIZE][MAPYSIZE][4];
		int m_XSize,m_YSize;
		int m_CameraX,m_CameraY;
		vector<CObject *> m_Objects;
		int m_RoomNum;
};

class CGUI
{
	public:
		CGUI();
		~CGUI();
		
		void Draw();
		void DrawBottom();
		void DrawTop();
		
		void ClearBottom();
		void ClearTop();
		void AddBottom(string s);
		void AddTop(string s,bool m);
		
		vector<string> m_BottomText;
		vector<string> m_TopText;
};

class CGame
{
	public:
		CGame();
		~CGame();
		
		void Load();
		void LoadObjects();
		void Run();
		void Generate(int sx,int sy,int ox,int oy);
		CObject *GetPlayer();
		CObject *GetType(int t);
		void Title();
		void SpawnObject(int n,int x,int y);
		CObject *AddGroup(string g,string g2,string g3,CObject *o);
		
		
		int m_SeenEnemies;
};

extern void Init();
extern void Exit();
		
extern bool Run();
extern void Input();
extern void Draw();
		
extern CGame m_Game;
extern CGUI m_GUI;
extern map<int,CRoom *> m_Rooms;
extern bool m_On;
extern CRoom *m_Room;
extern map<string,vector<CObject *> > m_MasterObjects;
extern int TotalTurns;


#endif




